package com.lfb.homework;

import java.util.ArrayList;
import java.util.Iterator;

public class HoneWork02 {
    public static void main(String[] args) {
        test01();
    }
    public static void test01(){
        ArrayList arrayList = new ArrayList();
        //给arrayList赋值
        for (int i = 1;i < 6;i++){
            arrayList.add(i);
        }
        System.out.println(arrayList.size());
        //迭代器遍历
        System.out.println("迭代器遍历");
        Iterator iterator = arrayList.iterator();
        while (iterator.hasNext()){
            Object obj = iterator.next();
            System.out.print(obj + "   ");
        }
        System.out.println();
        System.out.println("for循环遍历");
        for (int i=0;i<arrayList.size();i++){
            System.out.print(arrayList.get(i) + "  ");
        }
        System.out.println();
        System.out.println("增强型的for循环遍历");
        for (Object obj:arrayList){
            System.out.print(obj + "   ");
        }
    }
}
